import { BaseController, CoolController } from '@cool-midway/core';
import {ALL, Body, Get, Inject, Post, Provide} from "@midwayjs/decorator";
import {WxApiService} from "../../service/wxApi";

/**
 * 测试
 */
@Provide()
@CoolController()
export class DemoWxApiController extends BaseController {

  @Inject()
  wxApiService: WxApiService

  @Get('/getAccessToken', { summary: '获取accessToken' })
  async getAccessToken(){
    let data = await this.wxApiService.getAccessToken()
    return this.ok(data)
  }

  @Post('/getOpenid', { summary: '获取openid' })
  async getOpenid(@Body(ALL) body: any){
    let data = await this.wxApiService.getOpenid(body)
    return this.ok(data)
  }

  @Post('/login', { summary: '微信端登录' })
  async login(@Body(ALL) body: any){
    let result = await this.wxApiService.login(body)
    return this.ok(result)
  }

  @Post('/getShipsList', { summary: '根据userId获取赛艇列表' })
  async getShipsList(@Body(ALL) body: any){
    let result = await this.wxApiService.getShipsList(body)
    return this.ok(result)
  }
}
